package org.stwy.bills;

import javax.servlet.ServletRequest;
import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.stwy.lease.contract.ContractEntity;

import com.rap.common.exception.ServiceException;
import com.rap.frame.web.ActionResultModel;
import com.rap.frame.web.BaseController;

/*
 * 收费管理 控制类
 */
/**
*版权信息 (c) RAP 保留所有权利.
*@author 4028b22741f912710141f91290150000
*@Team RAP Team
*@Date 2015-6-25 21:55:39
*<p></p>
*
*@参与人：4028b22741f912710141f91290150000
*/

@Controller
@RequestMapping(value = "/bills/bills")
public class BillsController extends BaseController<BillsEntity> {

	public BillsController() {
		setResourceIdentity("stwy:bills"); //设置权限代码
	}
	private BillsService getService(){
		return (BillsService)super.baseService;
	}

	@RequestMapping(method = RequestMethod.GET)
	public String view(Model model) {
		super.assertHasViewPermission();
		return "stwy/bills/bills/bills_main";
	}

	@RequestMapping(value = "/select")
	public String select(Model model, String callback) {
		model.addAttribute("callback", callback);
		return "stwy/bills/bills/bills_select";
	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping(value = "/getPropertyByContractId")
	@ResponseBody
	public ActionResultModel getPropertyByContractId(ServletRequest request, Model model,String contractId) {
		ActionResultModel arm = new ActionResultModel();
		try {
			String[] info = getService().getPropertyByContractId(contractId);
			arm.setRecords(info);
			arm.setSuccess(true);
		} catch (ServiceException e) {
			e.printStackTrace();
			arm.setSuccess(false);
			arm.setMsg(e.getMessage());
		}catch (Exception e) {
			arm.setSuccess(false);
			arm.setMsg(e.getMessage());
			e.printStackTrace();
		}

		return arm;
	}
}
